﻿function fireParentForm(LevelLocationType, WebpartId, PermissionCode) {
    //alert('event from report form');
    if (LevelLocationType == "1") {
        $("#rowReportTypeHidden").show();
    }
    else
        $("#rowReportTypeHidden").hide();
}

function ClientSideCreateForm1() {

    var reporttimeIndex = document.getElementById("cbreportime").selectedIndex;
    var reportyearIndex = document.getElementById("cbreportyear").selectedIndex;
    var reportTypeIndex = document.getElementById("_cbreportType").selectedIndex;

    var reporttimeVal = document.getElementById("cbreportime").options[reporttimeIndex].value;
    var reportyearVal = document.getElementById("cbreportyear").options[reportyearIndex].value;
    var reportTypeVal = document.getElementById("_cbreportType").options[reportTypeIndex].value;

        var locationcodepeVal = $("#_locationsel").val();
        var locationType = $("#_locationLevelTypeSelect").val();

    if (!$("#_locationsel").length) {
        alert("Chọn đơn vị thực hiện báo cáo");
        return;
    }
    if (reporttimeIndex == 0 || reportyearIndex == 0) {
        alert("Chọn điều kiện để thực hiện báo cáo");
        return;
    }
    else {
        var reval = Portal.SODC.IDIS.ReportForms.ServerCreateReport(reportTypeVal, locationType, locationcodepeVal, reporttimeVal, reportyearVal).value;
        if (reval.indexOf("ERROR") != -1) {
            alert(reval);
            return;
        }
        window.open(reval, '_blank');
    }
}